import Page
from Page import Personal
from Base.Base import Base
from selenium.webdriver.common.by import By


class PersonalAuthorizeOpenPage(Base):
    """
    个人中心授权认证步骤
    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的home键
        self.authorize_home_btn = (By.XPATH, Personal.RESOURCE_ID.format("ivHome"))

        # 左侧的返回键
        self.authorize_back_btn = (By.XPATH, Personal.RESOURCE_ID.format('ivBack'))

        # 车辆确认图标
        self.authorize_step_one_icon = (By.XPATH, Personal.RESOURCE_ID.format("tv_step_first"))

        # 车辆确认名称
        self.authorize_step_one_name_text = (By.XPATH, Personal.RESOURCE_ID.format("tv_step_first_dec"))

        # 支付授权图标
        self.authorize_step_two_icon = (By.XPATH, Personal.RESOURCE_ID.format("tv_step_second"))

        # 支付授权名称
        self.authorize_step_two_name_text = (By.XPATH, Personal.RESOURCE_ID.format("tv_step_second_dec"))

        # 完成图标
        self.authorize_step_three_icon = (By.XPATH, Personal.RESOURCE_ID.format("tv_step_third"))

        # 完成名称
        self.authorize_step_three_name_text = (By.XPATH, Personal.RESOURCE_ID.format("tv_step_third_dec"))

        # 车牌号标题
        self.authorize_car_number_title_text = (By.XPATH, Personal.RESOURCE_ID.format("tv_plate"))

        # 车牌
        self.authorize_car_number_plate_text = (By.XPATH, Personal.RESOURCE_ID.format("tv_plate_number"))

        # 车牌数值
        self.authorize_car_number_input_text = (By.XPATH, Personal.RESOURCE_ID.format("et_input_number"))

        # 下一步
        self.authorize_next_step_btn = (By.XPATH, Personal.RESOURCE_ID.format("tv_next_step"))

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.authorize_home_btn)

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.authorize_back_btn)

    def get_step_one(self):
        """
        获取车辆确认图标

        :return:
        """
        return self.find_element_o(self.authorize_step_one_icon)

    def get_step_one_name(self):
        """
        获取车辆确认名称

        :return:
        """
        return self.find_element_o(self.authorize_step_one_name_text)

    def get_step_two(self):
        """
        获取支付授权图标

        :return:
        """
        return self.find_element_o(self.authorize_step_two_icon)

    def get_step_two_name(self):
        """
        获取支付授权名称

        :return:
        """
        return self.find_element_o(self.authorize_step_two_name_text)

    def get_step_three(self):
        """
        获取完成图标

        :return:
        """
        return self.find_element_o(self.authorize_step_three_icon)

    def get_step_three_name(self):
        """
        获取完成名称

        :return:
        """
        return self.find_element_o(self.authorize_step_three_name_text)

    def get_car_number_title(self):
        """
        获取车牌号标题

        :return:
        """
        return self.find_element_o(self.authorize_car_number_title_text)

    def get_car_number_plate(self):
        """
        获取车牌

        :return:
        """
        return self.find_element_o(self.authorize_car_number_plate_text)

    def get_car_number_input(self):
        """
        获取车牌数值

        :return:
        """
        return self.find_element_o(self.authorize_car_number_input_text)

    def click_next_step(self):
        """
        点击下一步按钮

        :return:
        """
        self.click_element(self.authorize_next_step_btn)

    def is_display_authorize_step(self):
        """
        是否存在授权信息步骤页

        :return: bool
        """
        return self.is_display(self.authorize_step_one_name_text)
